package lambdademo;

//函数接口，只有一个抽象方法
interface IA{
    void text();
    default void text1(){

    }
    public static void text2(){

    }
}
//无返回值无参数
@FunctionalInterface
interface NoParameterNoReturn {
    void test();
}
//无返回值一个参数
@FunctionalInterface
interface OneParameterNoReturn {
    void test(int a);
}
//无返回值多个参数
@FunctionalInterface
interface MoreParameterNoReturn {
    void test(int a,int b);
}
//有返回值无参数
@FunctionalInterface
interface NoParameterReturn {
    int test();
}
//有返回值一个参数
@FunctionalInterface
interface OneParameterReturn {
    int test(int a);
}
//有返回值多参数
@FunctionalInterface
interface MoreParameterReturn {
    int test(int a,int b);
}

public class Text {
    public static void main(String[] args) {
        OneParameterReturn oneParameterReturn=(a)->{return a+3;};
        System.out.println(oneParameterReturn.test(1));
    }
    public static void main4(String[] args) {
        //NoParameterReturn noParameterReturn=()->{return 10;};
        NoParameterReturn noParameterReturn1=()->10;
        System.out.println(noParameterReturn1.test());
    }
    public static void main3(String[] args) {
        MoreParameterNoReturn moreParameterNoReturn=(a,b)-> System.out.println(a+b);
        moreParameterNoReturn.test(10,2);
    }
    public static void main2(String[] args) {

        //OneParameterNoReturn oneParameterNoReturn=a->System.out.println(a);
        OneParameterNoReturn oneParameterNoReturn1=(int a)-> System.out.println(a);
        oneParameterNoReturn1.test(10);

    }
    public static void main1(String[] args) {
        NoParameterNoReturn noParameterNoReturn=new NoParameterNoReturn() {
            @Override
            public void test() {
                System.out.println("重写text方法");
            }
        };
        noParameterNoReturn.test();
        System.out.println("===========");

        NoParameterNoReturn noParameterNoReturn1=()-> System.out.println("重写text方法");
        noParameterNoReturn1.test();

    }

}
